const jsonwebtoken = require('jsonwebtoken');

//密钥
const secretKey = 'zzq1142744670'


//生成token
function sign(user) {
    try {
        const token = 'Bearer ' + jsonwebtoken.sign(user, secretKey, {expiresIn: "1day"}, false)
        return token
    } catch (e) {
        console.log(e)
    }

}


//解析token
function verify(token) {
    return jsonwebtoken.verify(token, secretKey, false, false)
}


module.exports = {
    sign, verify
}
